import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;

/**
 * @author fangkun
 * @create 2022-11-08-13:38
 */
public class CountLongWords {
    public static void main(String[] args) throws IOException {
        //读文件
        String contents = new String(Files.readAllBytes(
                Paths.get("D:\\test.txt")), StandardCharsets.UTF_8);
        //以非字母分隔
        List<String> words = Arrays.asList(contents.split("\\PL+"));

        long count = 0;

        for (String word : words) {
            if (word.length()>12) count++;
        }
        System.out.println(count);

        count = words.stream().filter(w -> w.length() > 12).count();
        System.out.println(count);

        count = words.parallelStream().filter(w -> w.length() > 12).count();
        System.out.println(count);
    }
}
